package com.zlzlib.logweb.controller;

import com.zlzlib.common.bean.EnumVo;
import com.zlzlib.log.bean.dto.ReqLogDto;
import com.zlzlib.log.bean.enums.LogType;
import com.zlzlib.log.bean.vo.LogListVo;
import com.zlzlib.log.bean.vo.LogStatusVo;
import com.zlzlib.log.service.LogSaveService;
import com.zlzlib.log.service.LogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @DateTime: 2023/3/9 17:31
 * @Author zlz
 * @Version 1.0
 */
@RestController
@RequestMapping("log")
@RequiredArgsConstructor
public class LogController {

    private final LogService logService;

    private final LogSaveService logSaveService;

    @GetMapping({"/query"})
    public LogListVo queryLogSystem(ReqLogDto dto) {
        try {
            return this.logService.getLogPage(dto);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new LogListVo();
    }

    @GetMapping("/getLogTypes")
    public List<EnumVo> getLogTypes() {
        return EnumVo.getEnumList(LogType.values());
    }

    @GetMapping("/getLogSaveStatus")
    public LogStatusVo getLogSaveStatus() {
        return logSaveService.getStatus();
    }

}
